package com.scuec.groupfive.mapper;

import com.scuec.groupfive.entity.UserInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;

@Mapper
public interface UserMapper_zm {

    @Select("SELECT * FROM users WHERE user_id = #{id}")
    UserInfo selectUserById(@Param("id") Integer id);

    @Select({
            "<script>",
            "SELECT * FROM users",
            "<where>",
            "  <if test='keyword != null and keyword.trim() neq \"\"'>",
            "    username LIKE CONCAT('%', #{keyword}, '%')",
            "    OR email LIKE CONCAT('%', #{keyword}, '%')",
            "  </if>",
            "</where>",
            "</script>"
    })
    List<UserInfo> selectUserListWithKeyword(@Param("keyword") String keyword);
}